using UnityEngine;

public class newcontroller : MonoBehaviour
{
	public static Vector3 joydir;

	public Transform m_transform;

	public Transform targetpoint;

	public Transform body;

	public Transform cam;

	public float speed;

	private Camera maincam;

	private Vector3 targetscreenpos;

	private Vector3 curpos;

	private Vector3 ScreenCenter;

	public AnimationCurve bodycurve;

	public Vector3 dir;

	private void Start()
	{
		m_transform = base.transform;
		maincam = Camera.main;
		ScreenCenter = new Vector3((float)Screen.width * 0.5f, (float)Screen.height * 0.5f, 0f);
	}

	private void Update()
	{
		uiNEWcon.instance.setposAim(maincam.WorldToScreenPoint(m_transform.position + m_transform.forward * 70f), istrue: true);
		m_transform.Translate(0f, 0f, speed * Time.deltaTime);
		m_transform.forward = targetpoint.position - m_transform.position;
		if (Vector3.Distance(UnityEngine.Input.mousePosition, ScreenCenter) < (float)Screen.height * 0.5f)
		{
			uiNEWcon.instance.setmouseaim(UnityEngine.Input.mousePosition, istrue: true);
			targetscreenpos = maincam.WorldToScreenPoint(m_transform.position + m_transform.forward * 70f);
			Camera camera = maincam;
			Vector3 mousePosition = UnityEngine.Input.mousePosition;
			float x = mousePosition.x;
			Vector3 mousePosition2 = UnityEngine.Input.mousePosition;
			curpos = camera.ScreenToWorldPoint(new Vector3(x, mousePosition2.y, targetscreenpos.z));
			targetpoint.position = Vector3.Lerp(targetpoint.position, curpos, 10f * Time.deltaTime);
			joydir = (UnityEngine.Input.mousePosition - ScreenCenter).normalized;
		}
		else
		{
			uiNEWcon.instance.setmouseaim(new Vector3((float)Screen.width * 0.5f, (float)Screen.height * 0.5f, 0f), istrue: true);
			targetscreenpos = maincam.WorldToScreenPoint(m_transform.position + m_transform.forward * 70f);
			curpos = maincam.ScreenToWorldPoint(new Vector3((float)Screen.width * 0.5f, (float)Screen.height * 0.5f, targetscreenpos.z));
			targetpoint.position = Vector3.Lerp(targetpoint.position, curpos, 10f * Time.deltaTime);
			joydir = Vector3.zero;
		}
		Vector3 vector = m_transform.InverseTransformPoint(targetpoint.position);
		if (!(vector.x > 0f))
		{
		}
	}
}
